/*************************************************************************
> File Name: 009NumbeReplies.cpp
> Author: icebear
> Mail: 3322366195@qq.com
> Created Time: 2023-08-07 11:29:15
> Description:回文数
************************************************************************/

#include <iostream>

using namespace std;
class Solution
{
public:
    bool isPalindrome(int x)
    {
        // 为负数结束，末尾为0且不为0返回
        if (x < 0 || (x % 10 == 0 && x != 0))
        {
            return false;
        }
        int i = 0;
        // 从后往前加直到相遇 判断是否相等
        while (x > i)
        {
            i = i * 10 + x % 10;
            x /= 10;
        }
        return x == i || x == i / 10;
    }
};
int main(int argc, char const *argv[])
{
    Solution s;
    cout << s.isPalindrome(1234321) << endl;

    return 0;
}
